//
//  EnterpriseListCell_iPad.m
//  WRY
//
//  Created by zhong sckj on 10-10-15.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "EnterpriseListCell_iPad.h"


@implementation EnterpriseListCell_iPad

@synthesize nameLabel;
@synthesize detailLabel;
@synthesize enterImageView;
@synthesize dataArray;
@synthesize currentIndex;
@synthesize enterpriseState;

-(void)changeText
{
	if (![dataArray count]) {
		return;
	}
	if (currentIndex>=[dataArray count]) {
		currentIndex=0;
	}
	
	NSDictionary *dict = [dataArray objectAtIndex:currentIndex];
	if ([enterpriseState isEqualToString:@"0"]) {
		detailLabel.textColor = [UIColor blueColor];
		detailLabel.text = [NSString stringWithFormat:@"%@ %@ 正常",[dict objectForKey:@"SiteName"],[dict objectForKey:@"StName"]];
	}
	else {
		NSString *onlineValue=[NSString stringWithFormat:@"%@",[dict objectForKey:@"Online"]];
		if ([onlineValue isEqualToString:@"0"]) {
			//正常
			detailLabel.textColor=[UIColor blueColor];
			detailLabel.text = [NSString stringWithFormat:@"%@ %@ 正常",[dict objectForKey:@"SiteName"],[dict objectForKey:@"StName"]];
		}
		else if([onlineValue isEqualToString:@"1"])
		{
			//超标
			detailLabel.textColor = [UIColor redColor];
			detailLabel.text = [NSString stringWithFormat:@"%@ %@ %.2f(%@)",[dict objectForKey:@"SiteName"],[dict objectForKey:@"StName"],
								[[dict objectForKey:@"OverData"] floatValue],[dict objectForKey:@"UName"]];
		}
		else {
			detailLabel.textColor=[UIColor grayColor];
			detailLabel.text = [NSString stringWithFormat:@"%@ %@ 故障或停产",[dict objectForKey:@"SiteName"],[dict objectForKey:@"StName"]];
		}
		
	}
	if ([dataArray count]>1) {
		CATransition *animation = [CATransition animation];
		animation.delegate = self;
		animation.duration = 0.5f;
		animation.timingFunction = UIViewAnimationCurveEaseInOut;
		animation.fillMode = kCAFillModeForwards;
		animation.endProgress =1;
		animation.removedOnCompletion = NO;
		animation.type = @"cube";
		[detailLabel.layer addAnimation:animation forKey:@"animation"];
		
	}
}
- (void)dealloc {
	[enterpriseState release];
	[enterImageView release];
	[nameLabel release];
	[detailLabel release];
    [super dealloc];
}



@end
